//
//  WSHeadView.m
//  GroupFourFM
//
//  Created by dllo on 15/12/25.
//  Copyright © 2015年 GroupFour. All rights reserved.
//

#import "WSHeadView.h"

@interface WSHeadView ()

@property (nonatomic, strong) WSBaseTitleLabel *titleLabel;
@property (nonatomic, strong) UILabel *contentLabel;

@end

@implementation WSHeadView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = WHITE;
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews {

    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.backgroundColor = CLEAR;
    imageView.image = [UIImage imageNamed:@"findsubject_cover@2x.png"];
    [self addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.top.mas_equalTo(@20);
        make.height.width.mas_equalTo(@40);
    }];
    
    self.titleLabel = [[WSBaseTitleLabel alloc] init];
    self.titleLabel.backgroundColor = CLEAR;
    self.titleLabel.numberOfLines = 2;
    self.titleLabel.font = [UIFont systemFontOfSize:17 weight:0];
    [self addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.equalTo(imageView);
        make.left.equalTo(imageView.mas_right).offset(10);
        make.right.mas_equalTo(@-20);
//        make.bottom
    }];
    
//    UIImageView *lineImage = [[UIImageView alloc] init];
//    lineImage.image = [UIImage imageNamed:@"findsubject_segline"];
//    lineImage.backgroundColor = [UIColor colorWithRed:0.93 green:0.93 blue:0.93 alpha:1];
//    [self addSubview:lineImage];
//    lineImage
    
    self.contentLabel = [[UILabel alloc] init];
    self.contentLabel.backgroundColor = CLEAR;
    self.contentLabel.text = @"暂无简介";
    self.contentLabel.numberOfLines = 0;
    self.contentLabel.font = [UIFont systemFontOfSize:15 weight:0];
    self.contentLabel.textColor = [UIColor lightGrayColor];
    [self addSubview:self.contentLabel];
    
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(imageView);
        make.top.equalTo(imageView.mas_bottom);
        make.right.equalTo(@-20);
        make.bottom.equalTo(self);
    }];

}

- (void)setInfoModel:(WSInfoModel *)infoModel {

    _infoModel = infoModel;
    self.titleLabel.text = _infoModel.title;
    self.contentLabel.text = _infoModel.intro;
    CGRect frame = self.contentLabel.frame;
    frame.size.height = infoModel.height;
    self.contentLabel.frame = frame;
}

@end
